
#include "TcpServer.hpp"
#include "Socket.hpp"
#include "Accepter.hpp"
#include <memory>
#include <iostream>

int main()
{
    //创建Tcp套接字
    std::unique_ptr<NetWorkModule::Socket> listenfd = std::make_unique<NetWorkModule::TcpSocket>();
    listenfd->BuildListenSocketMethod(8080, 10);

    //创建Tcp服务器
    std::unique_ptr<TcpServer> tcpServer = std::make_unique<TcpServer>();

    //创建conn连接
    ConnectionFactor factory;
    Connection* listenconn = factory.BuildListenConnection(listenfd->GetSockFd(), Accepter, EPOLLIN | EPOLLOUT, tcpServer.get());

    //将连接放在TcpServer里面去
    tcpServer->AddConnction(listenconn);
    tcpServer->EventDispatcher();
    return 0;
}